<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="common/common_head :: commonHead('意见反馈表管理')"></head>
</head>
<body class="larryms-auth">
<div class="layui-row larryms-panel">
    <div class="larryms-panel-heading layui-col-lg12 layui-col-md12 layui-col-sm12 layui-col-xs12">
        <span class="panel-tit">意见反馈表列表</span>
    </div>
    <div class="larryms-panel-body layui-col-lg12 layui-col-md12 layui-col-sm12 layui-col-xs12">
        <div class="larryms-tools">
            <form id="queryForm">
                <div class="larryms-search-box">
                    <div class="layui-inline">
                        <a class="layui-btn larryms-search" id="searchBtn" data-type="query"
                           data-form="queryForm"><i class="layui-icon layui-icon-search"></i>搜索</a>
                        <a class="layui-btn larryms-search" id="reloadBtn" data-type="reload"
                           data-form="queryForm"><i class="layui-icon layui-icon-refresh"></i></a>
                    </div>
                </div>
            </form>
            <div class="larryms-btn-group" style="margin-top:10px">
                <button class="layui-btn layui-btn-sm layui-btn-normal"  data-type="add"
                        data-title="新增意见反馈表"  th:attr="data-url=@{/admin/feedback/showAdd}">
                    <i class="layui-icon">&#xe61f;</i><cite>增加</cite></button>
                <button class="layui-btn layui-btn-sm" data-type="update"  data-title="修改意见反馈表"
                        th:attr="data-url=@{/admin/feedback/showUpdate}">
                    <i class="layui-icon">&#xe642;</i><cite>编辑</cite></button>
                <button class="layui-btn layui-btn-sm layui-btn-primary" data-type="detail"
                        data-title="查看意见反馈表详情" th:attr="data-url=@{/admin/feedback/showUpdate}">
                    <i class="larry-icon larry-file-markdown"></i><cite>查看</cite></button>
            </div>
        </div>
        <div class="user-list layui-col-lg12 layui-col-md12 layui-col-sm12 layui-col-xs12">
            <table id="feedbackList" lay-filter="feedbackList" class="larryms-table-id"
                   th:attr="data-url=@{/admin/feedback/list}"></table>
        </div>
    </div>
</div>
<script type="text/html" id="toolBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail" data-title="查看意见反馈表详情"
       th:attr="data-url=@{/admin/feedback/showUpdate}"><i class="larry-icon larry-file-markdown"></i>查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit" th:attr="data-url=@{/admin/feedback/showUpdate}" data-title="修改意见反馈表">
        <i class="layui-icon">&#xe642;</i>编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" th:attr="data-url=@{/admin/feedback/delete}">
        <i class="layui-icon layui-icon-delete"></i>删除</a>
</script>
<script type="text/javascript" th:src="@{/static/larryms/layui/layui.js}"/>
<script type="text/javascript" th:inline="javascript">/*<![CDATA[*/
    var table, bathPath = /*[[@{/}]]*/ "/";
    layui.config({
        version: ui.version,
        base: bathPath + 'static/larryms/',  //实际使用时，建议改成绝对路径
        rightMenu: "none" // false关闭，设置为custom时使用自定义，不使用默认menu
    }).extend({
        larry:'js/base'
    }).use(['larry','jquery','table', 'form','custom'],function () {
        var $ = layui.$, larryms = layui.larryms, form = layui.form , beone = layui.custom;
        table = layui.table;
        //按钮组监听
        $('.larryms-btn-group .layui-btn').on('click', function() {
            var type = $(this).data('type'),
                    url = $(this).data('url'),
                    tit = $(this).data('title');
            active[type] ? active[type].call(this, url, tit) : '';
        });

        $("#searchBtn,#reloadBtn").on('click', function() {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        var pageTableID = $('.larryms-table-id').attr('id');
        var dataUrl = $('#' + pageTableID).data('url')
        //方法级渲染
        table.render({
            id: pageTableID, elem: '#' + pageTableID , url: dataUrl,method:'POST'
            ,  cols: [[
                {checkbox: true, fixed: true, width: 30}
                            , {field: 'content', title: '反馈内容', minWidth: 100}
                            , {field: 'createUserId', title: '创建用户id', minWidth: 100}
                            , {field: 'deleteTag', title: '删除标识', minWidth: 100}
                            , {field: 'createTime', title: '创建时间', minWidth: 100}
                            , {field: 'updateTime', title: '修改时间', minWidth: 100}
                , {field: 'remark', title: '操作', minWidth: 200, toolbar: "#toolBar"}
            ]] , page: true ,request:{pageName:'page',limitName:'rows'}, height: 'full-200'
        });

        var active = {
            query: function () {
                var formId = $(this).data("form");
                table.reload(pageTableID, {
                    where: beone.serializeObject(formId)
                });
            },
            reload: function () {
                var formId = $(this).data("form");
                table.reload(pageTableID, {
                    where: beone.clearForm(formId)
                });
            },
            add: function (url , title) {
                var that = this;
                if ($(that).attr('data-flag') == 'exist') {
                    var index = layui.cache.layerIndex,
                    $max = $('#layui-layer' + index).find('.layui-layer-maxmin');
                    $max.click();
                    layui.cache.layerIndex = null;
                } else {
                    $(that).attr('data-flag', 'exist');
                    var index = beone.dialog({
                        title: title, url: url, width: 700, height: 500,
                        success: function (index, layero) {
                            form.render();
                        }, end: function () {
                            $(that).removeAttr("data-flag");
                            layui.cache.layerIndex = null;
                        }
                    });
                }
            },
            update: function (url , title) {
                var checkStatus = table.checkStatus(pageTableID)
                        , data = checkStatus.data;
                if (data.length != 1) {
                    layer.msg('请选择一行编辑', {icon: 5});
                    return false;
                }
                showUpdate(data[0].id, url, title,true);
            },
            detail: function (url , title) {
                var checkStatus = table.checkStatus(pageTableID)
                        , data = checkStatus.data;
                if (data.length != 1) {
                    layer.msg('请选择一行查看', {icon: 5});
                    return false;
                }
                showUpdate(data[0].id,  url, title,false);
            }
        };

        //监听工具条
        table.on('tool(' + pageTableID + ')', function (obj) {
            var data = obj.data;
            var url = $(this).data('url');
            var title = $(this).data('title');
            if (obj.event === 'detail') {
                showUpdate(data.id,url,title,false);
            } else if (obj.event === 'del') {
                var index = beone.confirm('确定删除意见反馈表[<label style="color: #00AA91;">该记录</label>]?',function () {
                    url = url + "/" + data.id;
                    beone.doRequest(url, {}, function () {
                        layer.close(index);
                        table.reload(pageTableID);
                    });
                })
            } else if (obj.event === 'edit') {
                showUpdate(data.id, url,title, true);
            }
        });
        function showUpdate(id, url,title,flag) {
            url += "/" + id + (flag ? "" : "?detail=true");
            beone.dialog({title:title, url:url, width:700, height:500});
        }
    });
/*]]>*/</script>
</body>
</html>